import java.util.ArrayList;
import java.util.List;

public class Solution1324 {
    public List<String> printVertically(String s) {
        List<String> list=new ArrayList<>();
        int len=0;
        String[] words=s.split(" ");
        for (String word : words) {
            len=Math.max(len,word.length());
        }
        for (int i=0;i<len;i++){
            list.add("");
        }
        for (String word : words) {
            for (int i=0;i<word.length();i++){
                list.set(i,list.get(i).concat(""+word.charAt(i)));
            }
            for (int i=word.length();i<len;i++){
                list.set(i,list.get(i).concat(" "));
            }
        }
        for (int i=0;i<len;i++){
            while (list.get(i).endsWith(" ")){
                list.set(i,list.get(i).substring(0,list.get(i).length()-1));
            }
        }
        return list;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1324().printVertically("TO BE OR NOT TO BE"));
    }
}
